<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<link href="../css/docs.css" type="text/css" rel="stylesheet" />
<link href="../css/prettify.css" type="text/css" rel="stylesheet" />
<script src="../js/prettify.js" type="text/javascript"></script>
</head>
<body onLoad="prettyPrint()">
<div class="g-unit" id="doc-content">
<div id="api-info-block">
    <div class="api-level">H3C CAS云管理平台</div>
  </div>
  <div id="jd-header">
    <h1>迁移虚拟机</h1>
  </div>
</div>
<div id="jd-content">
<div class="jd-descr">
<p>迁移指定的虚拟机，包括：只迁移主机、只迁移存储、迁移主机和存储三种迁移类型。</p>
<h2><a name="uri"></a>接口 URI</h2>
<p>/cas/casrs/vm/migrate</p>
<h2><a name="access"></a>访问方法</h2>
<dl>
  <dt><b>HTTP 方法</b></dt>
  <dd>PUT</dd>
  <dt><b>消息体</b></dt>
  <div class="source">
  	<pre class="prettyprint lang-xml">&lt;vmParamter&gt;	
    &lt;id&gt;49&lt;/id&gt;	
    &lt;domainName&gt;lxw&lt;/domainName&gt;	
    &lt;title&gt;lxw&lt;/title&gt;
    &lt;targetHostId&gt;2&lt;/targetHostId&gt;	
    &lt;onlineMigrate&gt;1&lt;/onlineMigrate&gt;	
    &lt;migrateType&gt;2&lt;/migrateType&gt;	
    &lt;targetPath>/vms/t28&lt;/targetPath&gt;	
    &lt;targetPool&gt;t28&lt;/targetPool&gt;	
    &lt;dstPersist&gt;true&lt;/dstPersist&gt;	
    &lt;dstSuspend&gt;false&lt;/dstSuspend&gt;	
&lt;/vmParamter&gt;<br>	</pre>
  </div>
</dl>

<dt><a name="detail"></a><b>元素含义</b></dt>
  <table id="pubmethods" class="jd-sumtable">
    <tbody>
      <tr class="alt-color">
        <th colspan="2"><span class="prettyprint lang-xml">vmParamter</span>各子元素</th>
      </tr>
      <tr>
        <td class="jd-typecol"><span class="prettyprint lang-xml">id</span></td>
        <td width="100%" class="jd-linkcol"><span class="sympad">需要迁移的虚拟机 ID。</span>
            <div class="jd-descrdiv">长整数（long）类型。</div></td>
      </tr>
      
      <tr class="alt-color">
        <td class="alt-color"><span class="prettyprint lang-xml">domainName</span></td>
        <td class="jd-linkcol"><span class="sympad">虚拟机名称，必填。</span>
          <div class="jd-linkcol">字符串（String）类型。</div></td>
      </tr>
      
      <tr>
        <td class="jd-typecol"><span class="prettyprint lang-xml">title</span></td>
        <td width="100%" class="jd-linkcol"><span class="sympad">虚拟机显示名称，必填。</span>
            <div class="jd-descrdiv">字符串（String）类型。</div></td>
      </tr>
      
      <tr class="alt-color">
        <td class="jd-typecol"><span class="prettyprint lang-xml">targetHostId</span></td>
        <td width="100%" class="jd-linkcol"><span class="sympad">目标主机 ID，必填。</span>
            <div class="jd-descrdiv">长整数（long）类型。</div></td>
      </tr>
	  <tr >
        <td class="jd-typecol"><span class="prettyprint lang-xml">onlineMigrate</span></td>
        <td width="100%" class="jd-linkcol"><span class="sympad">虚拟机状态，0:离线迁移虚拟机 1：在线迁移虚拟机，必填</span>
            <div class="jd-descrdiv">枚举(enum):0，1</div></td>
      </tr>
      <tr class="alt-color">
        <td class="jd-typecol"><span class="prettyprint lang-xml">migrateType</span></td>
        <td class="jd-linkcol"><span class="sympad">迁移类型，枚举:0表示只迁移主机，1表示只迁移存储，2表示迁移主机和存储，必填。</span>
          <div class="jd-descrdiv">枚举(enum):0，1，2</div></td>
      </tr>
          
      <tr >
        <td class="jd-typecol"><span class="prettyprint lang-xml">targetPath</span></td>
        <td class="jd-linkcol"><span class="sympad">迁移磁盘存储路径。</span>
          <div class="jd-descrdiv">字符串（String）类型。</div></td>
      </tr>
      
      <tr class="alt-color">
        <td class="jd-typecol"><span class="prettyprint lang-xml">targetPool</span></td>
        <td class="jd-linkcol"><span class="sympad">迁移磁盘存储池。</span>
          <div class="jd-descrdiv">字符串（String）类型。</div></td>
      </tr>
	  <tr >
        <td class="jd-typecol"><span class="prettyprint lang-xml">diskFormat</span></td>
        <td class="jd-linkcol"><span class="sympad">虚拟磁盘类型，枚举值：raw，qcow2。</span>
          <div class="jd-descrdiv">字符串（String）类型。</div></td>
      </tr>
      <tr class="alt-color">
        <td class="jd-typecol"><span class="prettyprint lang-xml">dstPersist</span></td>
        <td class="jd-linkcol"><span class="sympad">是否在目的主机上创建配置文件。</span>
          <div class="jd-descrdiv">布尔类型（Boolean）类型。</div></td>
      </tr>
	  <tr >
        <td class="jd-typecol"><span class="prettyprint lang-xml">dstSuspend</span></td>
        <td class="jd-linkcol"><span class="sympad">迁移到目标主机后是否暂停。</span>
          <div class="jd-descrdiv">布尔类型（Boolean）类型。</div></td>
      </tr>
	  <tr class="alt-color">
        <td class="jd-typecol"><span class="prettyprint lang-xml">compress</span></td>
        <td class="jd-linkcol"><span class="sympad">是否迁移压缩 true:压缩 false：不压缩。该参数只对在线迁移主机生效。</span>
          <div class="jd-descrdiv">布尔类型（Boolean）类型。</div></td>
      </tr>
  </table>

<h2><a name="result"></a>返回结果</h2>
<dl>
  <dt><b>状态码</b></dt>
  <dd>
  <ul>
    <li>200(OK)：提交删除任务成功。</li>
  </ul>
  <ul>
    <li>409(Conflict)：失败。</li>
  </ul>
  </dd>
  <dt><b>消息头</b></dt>
  <div class="source">
    <pre class="prettyprint lang-xml">HTTP/1.1 200 OK<br>Server: Apache-Coyote/1.1<br>Set-Cookie: JSESSIONID=BDF7B4EDFDBA9FBF003D195F802D705F; Path=/imcrs<br>Date: Fri, 23 Dec 2011 04:44:21 GMT
&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&gt;<br>&lt;taskMsg&gt;<br>  &lt;msgId&gt;1393831560400&lt;/msgId&gt;<br>  &lt;targetId&gt;3&lt;/targetId&gt;<br>  &lt;targetName&gt;vm110-1&lt;/targetName&gt;<br>  &lt;completed&gt;false&lt;/completed&gt;<br>  &lt;progress&gt;0&lt;/progress&gt;<br>&lt;/taskMsg&gt;</pre>
  </div>
</dl>
</dl>

    <h2><a name="example"></a>应用举例</h2>
    <p>迁移id为698的虚拟机，从id为77的主机迁移到id为78的主机，同时迁移虚拟机存储。</p>
    <dl>
      <dt><b>请求</b></dt>
      <div class="source">
        <pre class="prettyprint lang-xml">POST http://192.168.0.4:8080/cas/casrs/vm/migrate
accept: application/xml

&lt;vmParamter&gt;	
    &lt;id&gt;49&lt;/id&gt;	
    &lt;domainName&gt;lxw&lt;/domainName&gt;	
    &lt;title&gt;lxw&lt;/title&gt;
    &lt;targetHostId&gt;2&lt;/targetHostId&gt;	
    &lt;onlineMigrate&gt;1&lt;/onlineMigrate&gt;	
    &lt;migrateType&gt;2&lt;/migrateType&gt;	
    &lt;targetPath>/vms/t28&lt;/targetPath&gt;	
    &lt;targetPool&gt;t28&lt;/targetPool&gt;	
    &lt;dstPersist&gt;true&lt;/dstPersist&gt;	
    &lt;dstSuspend&gt;false&lt;/dstSuspend&gt;	
&lt;/vmParamter&gt;<br>
</pre>
      </div>
      <dt><b>回应</b></dt>
      <div class="source"><pre class="prettyprint lang-xml">HTTP/1.1 200 OK<br>Server: Apache-Coyote/1.1<br>Date: Mon, 21 May 2012 08:58:32 GMT<br>&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&gt;<br>&lt;taskMsg&gt;<br>  &lt;msgId&gt;1393831560400&lt;/msgId&gt;<br>  &lt;targetId&gt;3&lt;/targetId&gt;<br>  &lt;targetName&gt;vm110-1&lt;/targetName&gt;<br>  &lt;completed&gt;false&lt;/completed&gt;<br>  &lt;progress&gt;0&lt;/progress&gt;<br>  &lt;eventType&gt;0&lt;/eventType&gt;<br>&lt;/taskMsg&gt;</pre>
      </div>
    </dl>
    
</div>
</div>
</div>
</body>
</html>